var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (t, i) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, t) {
              e.__proto__ = t;
            }) ||
          function (e, t) {
            for (var i in t)
              Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
          })(t, i);
      };
      return function (t, i) {
        function a() {
          this.constructor = t;
        }
        if ("function" != typeof i && null !== i)
          throw new TypeError(
            "Class extends value " + String(i) + " is not a constructor or null"
          );
        e(t, i),
          (t.prototype =
            null === i
              ? Object.create(i)
              : ((a.prototype = i.prototype), new a()));
      };
    })(),
  GameSecenPageView = (function (e) {
    function t() {
      var t = e.call(this) || this;
      return (
        (t.dataArr = []),
        (t.resultArr = []),
        (t.myIsCaptain = !1),
        t.btn_pageView_back.on(Laya.Event.CLICK, t, t.onGamePageViewClick),
        t.btn_gameScence_duiwuliebiao.on(
          Laya.Event.CLICK,
          t,
          t.onGameScenceDuiwuliebiaoAction
        ),
        t.label_game_xuanzexiaohao.on(
          Laya.Event.CLICK,
          t,
          t.onDidXuanZeXiaoHaoDownClick
        ),
        t.label_game_xuanzexiaohao1.on(
          Laya.Event.CLICK,
          t,
          t.onDidXuanZeXiaoHaoDownClick
        ),
        (t.list_gameScence_page.vScrollBarSkin = ""),
        (t.list_gameScence_page.selectEnable = !0),
        t.list_gameScence_page.on(Laya.Event.CLICK, t, t.onXuanZeXiaoHaoAction),
        (t.list_gamePage_duiwu.vScrollBarSkin = ""),
        (t.list_gamePage_duiwu.selectEnable = !0),
        t.list_gamePage_duiwu.on(Laya.Event.CLICK, t, t.onXuanZeDuiWuAction),
        (t.list_fuben_myDuiWu.renderHandler = new Laya.Handler(
          t,
          t.updateGroupTeamCellItem
        )),
        t.list_fuben_myDuiWu.on(Laya.Event.CLICK, t, t.onOperationMyTeamAction),
        t.btn_gameScence_jinrufuben.on(
          Laya.Event.CLICK,
          t,
          t.onJinRuFuBenAction
        ),
        t.btn_fuben_chuangjianduiwu.on(
          Laya.Event.CLICK,
          t,
          t.onChuangJianDuiWuAction
        ),
        t.btn_fuben_jiesanduiwu.on(Laya.Event.CLICK, t, t.onJieSanDuiWuAction),
        WebSocketService.addListener({
          caller: t,
          code: 1807,
          method: t.onLoadFuBenXiangQingData,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 18071,
          method: t.onLoadFuBenDuiwuData,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 1802,
          method: t.onLoadJiaRuDuiWuData,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 18041,
          method: t.onLoadDuWuXiangQingData,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 18236,
          method: t.onLoadJieSanDuiWuData,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 1805,
          method: t.onLoadJinRuFuBenData,
        }),
        t
      );
    }
    return (
      __extends(t, e),
      (t.showGameSecenPageView = function (e) {
        return (
          null == this.pageView && (this.pageView = new t()),
          WebSocketService.send({ c: 1807, d: { fbId: e.id } }),
          (this.pageView.jsonDict = e),
          this.pageView.setupUI("1"),
          this.pageView
        );
      }),
      (t.prototype.setupUI = function (e) {
        "1" == e
          ? ((this.scenceStr = "1"),
            (this.item_gameSence_bg1.visible = !0),
            (this.item_gameSence_bg2.visible = !1),
            (this.item_gameSence_bg3.visible = !1),
            this.item1ViewData())
          : "2" == e
          ? ((this.scenceStr = "2"),
            (this.item_gameSence_bg1.visible = !1),
            (this.item_gameSence_bg2.visible = !0),
            (this.item_gameSence_bg3.visible = !1),
            this.item2ViewData())
          : "3" == e &&
            ((this.scenceStr = "3"),
            (this.item_gameSence_bg1.visible = !1),
            (this.item_gameSence_bg2.visible = !1),
            (this.item_gameSence_bg3.visible = !0),
            this.item3ViewData(),
            this.myIsCaptain
              ? (this.btn_fuben_jiesanduiwu.visible = !0)
              : (this.btn_fuben_jiesanduiwu.visible = !1));
      }),
      (t.prototype.item1ViewData = function () {
        this.list_gameScence_page.visible = !1;
      }),
      (t.prototype.item2ViewData = function () {}),
      (t.prototype.item3ViewData = function () {}),
      (t.prototype.onDidXuanZeXiaoHaoDownClick = function () {
        (this.dataArr = [{ 2: "体力值" }, { 3: "兵符" }]),
          (this.resultArr = []);
        for (var e, t = 0; t < this.dataArr.length; t++) {
          var i = t + 2;
          (e = { item_bang: { text: this.dataArr[t][i] } }),
            this.resultArr.push(e);
        }
        (this.list_gameScence_page.visible = !0),
          (this.list_gameScence_page.dataSource = this.resultArr);
      }),
      (t.prototype.onXuanZeXiaoHaoAction = function (e) {
        if ("" != e.target.name) {
          var t = this.list_gameScence_page.selectedIndex + 2,
            i = this.dataArr[this.list_gameScence_page.selectedIndex];
          (this.label_game_xuanzexiaohao.text = i[t]),
            (this.list_gameScence_page.visible = !1);
        } else this.list_gameScence_page.visible = !1;
      }),
      (t.prototype.onLoadFuBenXiangQingData = function (e) {
        if (0 == e.code) {
          var t = "等级：" + e.data.lvl + "\n",
            i = "人数：1~" + e.data.players_limit + "人\n",
            a = "时限：" + e.data.time_limit + "分钟\n";
          this.label_fuben_xiangqing.text = t + i + a;
        }
      }),
      (t.prototype.onGameScenceDuiwuliebiaoAction = function () {
        var e = this.label_game_xuanzexiaohao.text,
          t = this.jsonDict.id;
        "体力值" == e
          ? WebSocketService.send({ c: 18071, d: { fbId: t, goods: 1 } })
          : WebSocketService.send({ c: 18071, d: { fbId: t, goods: 2 } });
      }),
      (t.prototype.onLoadFuBenDuiwuData = function (e) {
        if (0 == e.code) {
          this.setupUI("2");
          for (var t = void 0, i = [], a = e.data, n = 0; n < a.length; n++) {
            var o = a[n];
            (t = {
              item_name: { text: o.roomName + "  的小队" },
              item_detail: { text: "" },
              cid: o.cid,
              pwd: o.pwd,
            }),
              i.push(t);
          }
          (this.list_gamePage_duiwu.dataSource = i),
            (this.btn_fuben_chuangjianduiwu.visible = !0);
        } else
          (this.btn_fuben_chuangjianduiwu.visible = !1),
            "体力值不足" != e.msg && WebSocketService.send({ c: 18041 }),
            ToastView.toastView(e.msg);
      }),
      (t.prototype.onXuanZeDuiWuAction = function (e) {
        if ("" != e.target.name) {
          var t = this.list_gamePage_duiwu.selectedItem;
          t.pwd.length > 0
            ? NormalInputDialog.showNormalInputDialog(this, this.onInputDialog)
            : WebSocketService.send({
                c: 1802,
                d: { fbId: this.jsonDict.id, cid: t.cid, pwd: "" },
              });
        }
      }),
      (t.prototype.onInputDialog = function (e) {
        var t = this.list_gamePage_duiwu.selectedItem;
        WebSocketService.send({
          c: 1802,
          d: { fbId: this.jsonDict.id, cid: t.cid, pwd: e },
        });
      }),
      (t.prototype.onLoadJiaRuDuiWuData = function (e) {
        0 == e.code
          ? (this.setupUI("3"), WebSocketService.send({ c: 18041 }))
          : ToastView.toastView(e.msg);
      }),
      (t.prototype.onLoadDuWuXiangQingData = function (e) {
        if (0 == e.code) {
          var t = void 0;
          this.setupUI("3");
          for (var i = e.data, a = [], n = 0; n < i.length; n++) {
            var o = i[n];
            (t = {
              itemName: {
                text:
                  this.dealIsCaptain(o.isCaptain) +
                  ":" +
                  o.userName +
                  "(" +
                  o.lvl +
                  "级)",
              },
              isCaptain: o.isCaptain,
              lvl: o.lvl,
              roleId: o.roleId,
              userName: o.userName,
            }),
              a.push(t);
          }
          a.push({
            itemName: { text: "无" },
            isCaptain: "0",
            lvl: "",
            roleId: "",
            userName: "",
          }),
            (this.list_fuben_myDuiWu.dataSource = a),
            (this.list_fuben_myDuiWu.visible = !0),
            (this.btn_fuben_chuangjianduiwu.visible = !1),
            e.data.length > 0 &&
              ((this.label_duiwu_name.text = e.data[0].userName + "的队伍"),
              1 == e.data[0].isCaptain &&
                e.data[0].roleId == Global.roleId &&
                (this.myIsCaptain = !0));
        } else this.btn_fuben_chuangjianduiwu.visible = !0;
      }),
      (t.prototype.dealIsCaptain = function (e) {
        return 1 == e ? "队长" : "队员";
      }),
      (t.prototype.onChuangJianDuiWuAction = function () {
        GameTeamDialog.showGameFuBenDialog(this.jsonDict);
      }),
      (t.prototype.onJieSanDuiWuAction = function () {
        NormalDialog.showNormalDialog(
          "您确定解散队伍",
          this,
          this.onquedingjiesanduiwu
        );
      }),
      (t.prototype.onquedingjiesanduiwu = function () {
        WebSocketService.send({ c: 18236 });
      }),
      (t.prototype.onLoadJieSanDuiWuData = function (e) {}),
      (t.prototype.updateGroupTeamCellItem = function (e, t) {
        var i = e.getChildByName("item_yaoqing");
        i.visible = !0;
        var a = e.dataSource,
          n = "";
        1 == a.isCaptain && (i.visible = !1),
          this.myIsCaptain
            ? ((n = a.roleId ? "剔出" : "邀请"),
              a.roleId == Global.roleId && ((n = ""), (i.visible = !1)))
            : a.roleId == Global.roleId
            ? ((n = ""), (i.visible = !1))
            : (n = "邀请"),
          (i.label = n);
      }),
      (t.prototype.onOperationMyTeamAction = function (e) {
        if ("" != e.target.name && "邀请" == e.target.label) {
          TeamInvitateDialog.showTeamListView({ type: "fuben" });
        }
      }),
      (t.prototype.onJinRuFuBenAction = function () {
        WebSocketService.send({ c: 1805 });
      }),
      (t.prototype.onLoadJinRuFuBenData = function (e) {
        0 == e.code
          ? ((Global.isFuBen = !0),
            Laya.stage.removeChildByName("GameSecenMainView"),
            Laya.stage.removeChildByName("battlefield"),
            this.removeSelf(),
            Laya.stage.event("GameMainView", "loadingFuben"),
            Laya.stage.event("GameMainView", "loadingFuben_MainTab"),
            Laya.stage.event("HomePageView", "loadingFuben"),
            Laya.stage.event("HomePageView", "loadingFuben_MainTab"))
          : ToastView.toastView(e.msg);
      }),
      (t.prototype.onGamePageViewClick = function () {
        this.removeSelf();
      }),
      t
    );
  })(ui.battlefield.GameSecenPageViewUI);
